package com.thread;

/**
 * Created by john on 2016/4/7.
 */
public class SuspendTest extends Thread{

    private long  i =0;

    public long getI() {
        return i;
    }

    public void setI(long i) {
        this.i = i;
    }

    @Override
    public void run() {
        while(true){
            i++;
        }
    }

    public static void main(String[] args) {
       try{
           SuspendTest t = new SuspendTest();
           t.start();
           Thread.sleep(100);
           t.suspend();//暂停
           System.out.println(System.currentTimeMillis()+":"+t.getI());
           Thread.sleep(100);
           System.out.println(System.currentTimeMillis()+":"+t.getI());

           t.resume();
           Thread.sleep(100);
           t.suspend();
           System.out.println(System.currentTimeMillis()+":"+t.getI());


           Thread.sleep(100);
           System.out.println(System.currentTimeMillis()+":"+t.getI());

       }catch (Exception e){
           e.printStackTrace();
       }

    }
}
